package com.lim.demo.controller;

import com.lim.demo.service.eventService;
import com.lim.demo.utils.AjaxResult;
import com.lim.demo.utils.PageRequest;
import com.lim.demo.utils.PageResult;
import com.lim.demo.utils.StringUtils;
import io.swagger.annotations.*;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 历史事件数据统一控制器
 * </p>
 *
 * @author liulijin
 * @since 2021-01-22
 */
/**
 * 登录接口类
 */
@Api(value = "历史事件数据请求接口类", tags = "历史事件数据", description = "历史事件数据")
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "请求已完成"),
        @ApiResponse(code = 201, message = "资源成功被创建"),
        @ApiResponse(code = 400, message = "请求中有语法问题，或不能满足请求"),
        @ApiResponse(code = 401, message = "未授权客户机访问数据"),
        @ApiResponse(code = 403, message = "服务器接受请求，但是拒绝处理"),
        @ApiResponse(code = 404, message = "服务器找不到给定的资源；文档不存在"),
        @ApiResponse(code = 500, message = "服务器出现异常")}
)
@RestController
@RequestMapping("/fous")
@Log4j2
public class HistoricalEventsController {



    @Autowired
    private eventService eventService;

    public PageRequest pageQuery;

    /**
     * @author liulijin
     * @date 2021/1/22 14:17
     * @description 获取事件列表
     * @param
     * @return
     */
    @ApiOperation(value = "历史数据查询接口", notes = "历史数据查询接口", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "regionCode", value = "区划编码", required = true, dataType = "string"),
            @ApiImplicitParam(name = "serialNum", value = "流水号", required = true, dataType = "string"),
            @ApiImplicitParam(name = "sponsorName", value = "上报人", required = true, dataType = "string"),
            @ApiImplicitParam(name = "title", value = "事件名称", required = true, dataType = "string"),
            @ApiImplicitParam(name = "state", value = "事件状态", required = true, dataType = "string"),
            @ApiImplicitParam(name = "sendType", value = "办结类型", required = true, dataType = "string"),
            @ApiImplicitParam(name = "flowClassifyName", value = "事项大类", required = true, dataType = "string"),
            @ApiImplicitParam(name = "flowClassifyType", value = "事项小类", required = true, dataType = "string"),
            @ApiImplicitParam(name = "startTime", value = "上报起始时间", required = true, dataType = "string"),
            @ApiImplicitParam(name = "endTime", value = "上报截止时间", required = true, dataType = "string"),
            @ApiImplicitParam(name = "disposalLevel", value = "处置级别", required = true, dataType = "string"),
            @ApiImplicitParam(name = "type", value = "事件类型", required = true, dataType = "string"),
            @ApiImplicitParam(name = "polic", value = "双网融合", required = true, dataType = "string")
    })
    @RequestMapping(value = "/getEventList",method = RequestMethod.POST)
    public AjaxResult getEventList(String  regionCode,String sponsorName,String  serialNum,String  title,String  state,String  sendType,String  flowClassifyName,String  flowClassifyType,String  startTime,String  endTime,String  disposalLevel,String  type,String  polic,String flowType,String pageNum,String pageSize) {
        pageQuery = new PageRequest();
        pageQuery.setPageNum(Integer.parseInt(pageNum));
        pageQuery.setPageSize(Integer.parseInt(pageSize));
        regionCode = "32058301";
        PageResult page = eventService.findPage(pageQuery, regionCode, sponsorName, serialNum, title, state, sendType, flowClassifyName, flowClassifyType, startTime, endTime, disposalLevel, type, polic, StringUtils.isBlank(flowType) ? "KSSJSB" : "KS331SJSB");


        AjaxResult ajax=new AjaxResult(200,"成功",page.getContent());

        return ajax;
    }
}
